package com.puxsoft.example.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.puxsoft.example.domain.Customer;

//@Configuration    //该注解类似于spring配置文件
//@MapperScan(basePackages="com.puxsoft.example.mapper")

@Mapper
public interface CustomerMapper {
	
	@Insert("INSERT INTO px_customer(CUSTOMER_NAME,PHONE) VALUES(#{customerName},#{phone})")
	public void insertCustomer(@Param("customerName") String customerName,@Param("phone") String phone);

	
	@Insert("INSERT INTO px_customer(CUSTOMER_NAME,PHONE) VALUES(#{customerName},#{phone})")
	//@Options(useGeneratedKeys=true,keyProperty="CUSTOMER_ID")
	public int insertCustomerDomain(Customer customer);


    public int insertUserWithOld(Customer customer);
    
    @Select("SELECT * FROM PX_CUSTOMER WHERE CUSTOMER_ID = #{customerId}")
    @Results(value = {@Result(id = true,column ="CUSTOMER_ID",property="customerId"),@Result(column ="CUSTOMER_NAME",property="customerName")})
    public Customer findById(@Param("customerId") String customerId);
    
    @Select("SELECT * FROM PX_CUSTOMER")
    @Results(value = {@Result(id = true,column ="CUSTOMER_ID",property="customerId"),@Result(column ="CUSTOMER_NAME",property="customerName")})
    public List<Customer> findAll();
    
}
